package sort;

import java.util.Arrays;

public class InsertSort {
    private static final int[] a = {2, 4, 1, 5, 7, 3, 9, 6, 8, 0};

    public static void main(String[] args) {
        insertSort();
        System.out.println(Arrays.toString(a));
    }

    private static void insertSort() {
        for (int i = 1; i < a.length; i++) {
            int key = a[i];
            int j = i - 1;
            while (j >= 0 && a[j] > key) {
                a[j+1] = a[j];
                j--;
            }
            a[j+1] =key;
        }
    }
}
